import React, { Component } from 'react'

export default class ShowCom extends Component {
  state = {
    count: 0
  }
  //构造方法
  constructor(){
    console.log('1.构造方法');
    super();
  }

  render() {
    console.log('2.render方法');
    return (
      <div>
        <h2>{this.state.count}</h2>
        <button onClick={() => {
          //更新状态
          this.setState({
            count: this.state.count + 1
          })
        }}>新增</button>
      </div>
    )
  }

  //组件挂载完毕的钩子
  componentDidMount(){
    console.log('3.组件挂载完毕');
  }

  //组件完成更新的钩子
  componentDidUpdate(){
    console.log('组件完成了更新')
  }

  //组件将要卸载
  componentWillUnmount(){
    console.log('组件将要卸载');
  }
}
